package com.wf.day_0619.test3.jdk;

import com.wf.day_0619.test3.CalculatorServiceImpl;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author mpk
 * @since 2024/6/19 19:09:20
 */
public class MyInvocationHandler implements InvocationHandler {

    private CalculatorServiceImpl target;

    public MyInvocationHandler(CalculatorServiceImpl target) {
        this.target = target;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("开始执行"+method.getName()+"方法");

        Object invoke = method.invoke(target, args);

        System.out.println(method.getName()+"执行完毕！");

        return invoke;
    }
}
